﻿using B.S.DataBase.MyProject.Domain.SaleOrders;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using MediatR;
using T.E.ERP.Read.API.Applicantions.Command.MyOrdermementCommands;

namespace T.E.ERP.Read.API.Applicantions.CommandHandler.MyOrdermementHandlers
{
    public class SelQinggouHandler : IRequestHandler<SelQinggouCommand, APIResult<List<JoinGetOrder>>>
    {
        private readonly IBaseRepository<JoinGetOrder> _JoinGetOrder;

        public SelQinggouHandler(IBaseRepository<JoinGetOrder> joinGetOrder)
        {
            _JoinGetOrder = joinGetOrder;
        }

        public async Task<APIResult<List<JoinGetOrder>>> Handle(SelQinggouCommand request, CancellationToken cancellationToken)
        {
            var result = new APIResult<List<JoinGetOrder>>()
            {
                Code = APIEnum.查询成功,
                Msg = APIEnum.查询成功.ToString()
            };
            var list= _JoinGetOrder.GetAll().Result.ToList();
            result.data = list;
            return await Task.FromResult(result);
        }
    }
}
